package com.tedu.service.impl;

import com.tedu.dao.UserDao;
import com.tedu.dao.impl.UserDaoImpl;
import com.tedu.entry.User;
import com.tedu.entry.vo.UserVO;
import com.tedu.service.UserService;

/**
 * Author：毕龙
 * Date: 2023/7/28 10:27
 */
public class UserServiceImpl implements UserService {
    //创建Dao对象
    private UserDao userDao = new UserDaoImpl();

    @Override
    public User selectUserByUP(UserVO userVO) {
        //处理业务逻辑
        String username = userVO.getUsername();
        //判断用户名是否为空
        if(username == null || username == ""){
            throw new RuntimeException("用户名为null");
        }

        //调用数据层获取数据的信息
        User user = userDao.selectUserByUP(userVO);

        //判断user是否存在
        if(user == null){
            throw new RuntimeException("用户名或密码错误");
        }

        return user;
    }
}
